#include "../code/server.hpp"



void ConnectCallBack(const PtrConnection& conn)
{
    LOG(Info, "链接创建成功 %p", conn.get());
}

void MessageCallBack(const PtrConnection& conn, Buffer* buf)
{
    LOG(Info, "%s", buf->ReadPos());
    buf->MoveReadOffset(buf->ReadableSize());
    std::string str = "hello muduo";
    // std::cout << "***********" << std::endl;
    conn->Send(str.c_str(), str.size());
    //conn->Shutdown();
}

void CloseCallback(const PtrConnection& conn)
{
    LOG(Info, "close");
}

void AnyCallback(const PtrConnection& conn)
{
    // LOG(Info, "来了一个任务");
}


int main()
{
    TcpServer server(8080);
    server.SetThreadCount(3);
    server.EnableInactiveRelease(10);
    
    server.SetConnectCallback(ConnectCallBack);
    server.SetMessageCallback(MessageCallBack);
    server.SetClosedCallback(CloseCallback);

    server.Start();

    return 0;
}
